package biz

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

const (
	CodeSuccess = 0
	CodeFail    = -1
)

var MsgMap = map[int]string{
	CodeSuccess: "成功",
	CodeFail:    "失败",
}

type H struct {
	Code  int
	Msg   string
	Data  interface{}
	Rows  interface{}
	Total interface{}
}

func Resp(ctx *gin.Context, code int, data interface{}, msg string) {
	resp := H{
		Code: code,
		Msg:  msg,
		Data: data,
	}
	ctx.JSON(http.StatusOK, resp)
}
func RespList(ctx *gin.Context, code int, data interface{}, total interface{}) {
	ctx.JSON(http.StatusOK, H{
		Code:  code,
		Data:  data,
		Total: total,
	})
	return
}
